﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FilterPattern
{
    public class OrFilter : Filter
    {
        private Filter filter;
        private Filter otherFilter;

        public OrFilter(Filter filter, Filter otherFilter)
        {
            this.filter = filter;
            this.otherFilter = otherFilter;
        }

        public List<Person> MeetFilter(List<Person> persons)
        {
            List<Person> firstFilterPersons = filter.MeetFilter(persons);
            List<Person> otherFilterPersons = filter.MeetFilter(persons);

            foreach (var item in otherFilterPersons)
            {
                if (!firstFilterPersons.Contains(item))
                {
                    firstFilterPersons.Add(item);
                }
            }

            return firstFilterPersons;
        }
    }
}
